<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns:MSHelp="http://www.microsoft.com/MSHelp/" lang="en-us" xml:lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="DC.Type" content="topic">
<meta name="DC.Title" content="Empty Tasks">
<meta name="DC.subject" content="Empty Tasks">
<meta name="keywords" content="Empty Tasks">
<meta name="DC.Relation" scheme="URI" content="../tbb_userguide/Useful_Task_Techniques.htm">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="tutorial_Empty_Tasks">
<link rel="stylesheet" type="text/css" href="../intel_css_styles.css">
<title>Empty Tasks</title>
<xml>
<MSHelp:Attr Name="DocSet" Value="Intel"></MSHelp:Attr>
<MSHelp:Attr Name="Locale" Value="kbEnglish"></MSHelp:Attr>
<MSHelp:Attr Name="TopicType" Value="kbReference"></MSHelp:Attr>
</xml>
</head>
<body id="tutorial_Empty_Tasks">
 <!-- ==============(Start:NavScript)================= -->
 <script src="..\NavScript.js" language="JavaScript1.2" type="text/javascript"></script>
 <script language="JavaScript1.2" type="text/javascript">WriteNavLink(1);</script>
 <!-- ==============(End:NavScript)================= -->
<a name="tutorial_Empty_Tasks"><!-- --></a>


<h1 class="topictitle1">Empty Tasks</h1>

<div><p>You might need a task that does not do anything but wait for its children to complete. The header <samp class="codeph">task.h</samp> defines class <samp class="codeph">empty_task</samp> for this purpose. Its definition is as follows:</p>
<pre>// Task that does nothing. Useful for synchronization.
class empty_task: public task {
    /*override*/ task* execute() {
        return NULL;
    }
};</pre><p>A good example of <samp class="codeph">empty_task</samp> in action is provided in <samp class="codeph">tbb/parallel_for</samp>.<samp class="codeph">h</samp>, in method <span class="option">start_for::execute()</span>. The code there uses continuation-passing style. It creates two child tasks, and uses an <samp class="codeph">empty_task</samp> as the continuation when the child tasks complete. The top level routine <samp class="codeph">parallel_for</samp> (in <samp class="codeph">tbb/parallel_for</samp>.<samp class="codeph">h</samp>) waits on the root.</p>
</div>

<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong>&nbsp;<a href="../tbb_userguide/Useful_Task_Techniques.htm">Useful Task Techniques</a></div>
</div>
<div></div>

</body>
</html>
